<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Opens file or URL</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="streamwrapper.stream-metadata.html">streamWrapper::stream_metadata</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="streamwrapper.stream-read.html">streamWrapper::stream_read</a></div>
 <div class="up"><a href="class.streamwrapper.html">streamWrapper</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="streamwrapper.stream-open" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">streamWrapper::stream_open</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.2, PHP 5)</p><p class="refpurpose"><span class="refname">streamWrapper::stream_open</span> &mdash; <span class="dc-title">Opens file or URL</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-streamwrapper.stream-open-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>streamWrapper::stream_open</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$mode</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$opened_path</code></span>
   )</div>

  <p class="para rdfs-comment">
   This method is called immediately after the wrapper is initialized (f.e. by
   <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span> and <span class="function"><a href="function.file-get-contents.html" class="function">file_get_contents()</a></span>).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-streamwrapper.stream-open-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">path</code></em></dt>

     <dd>

      <p class="para">
       Specifies the URL that was passed to the original function.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        The URL can be broken apart with <span class="function"><a href="function.parse-url.html" class="function">parse_url()</a></span>.  Note that only URLs
        delimited by :// are supported. : and :/ while technically valid URLs, are not.
       </p>
      </p></blockquote>
     </dd>

    
    
     <dt>
<em><code class="parameter">mode</code></em></dt>

     <dd>

      <p class="para">
       The mode used to open the file, as detailed for <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        Remember to check if the <em><code class="parameter">mode</code></em> is valid for the
        <em><code class="parameter">path</code></em> requested.
       </p>
      </p></blockquote>
     </dd>

    
    
     <dt>
<em><code class="parameter">options</code></em></dt>

     <dd>

      <p class="para">
       Holds additional flags set by the streams API. It can hold one or more
       of the following values OR&#039;d together.
       <table class="doctable informaltable">
        
         <thead>
          <tr>
           <th>Flag</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><strong><code>STREAM_USE_PATH</code></strong></td>
           <td>If <em><code class="parameter">path</code></em> is relative, search
            for the resource using the include_path.
           </td>
          </tr>

          <tr>
           <td><strong><code>STREAM_REPORT_ERRORS</code></strong></td>
           <td>If this flag is set, you are responsible for raising
            errors using <span class="function"><a href="function.trigger-error.html" class="function">trigger_error()</a></span> during
            opening of the stream.  If this flag is not set, you
            should not raise any errors.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">opened_path</code></em></dt>

     <dd>

      <p class="para">
       If the <em><code class="parameter">path</code></em> is opened successfully,
       and <strong><code>STREAM_USE_PATH</code></strong> is set in <em><code class="parameter">options</code></em>,
       <em><code class="parameter">opened_path</code></em> should be set to the full
       path of the file/resource that was actually opened.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-streamwrapper.stream-open-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-streamwrapper.stream-open-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">调用此方法失败将给出
<strong><code>E_WARNING</code></strong>（未实现）。</p>
 </div>

 



 <div class="refsect1 notes" id="refsect1-streamwrapper.stream-open-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">当合法的上下文传递给调用函数时，属性
<var class="varname"><var class="varname">streamWrapper::$context</var></var>
会被改变。</p></p></blockquote>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-streamwrapper.stream-open-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.fopen.html" class="function" rel="rdfs-seeAlso">fopen()</a> - 打开文件或者 URL</span></li>
    <li class="member"><span class="function"><a href="function.parse-url.html" class="function" rel="rdfs-seeAlso">parse_url()</a> - 解析 URL，返回其组成部分</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="streamwrapper.stream-metadata.html">streamWrapper::stream_metadata</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="streamwrapper.stream-read.html">streamWrapper::stream_read</a></div>
 <div class="up"><a href="class.streamwrapper.html">streamWrapper</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
